/**
 * 给定当前时刻，求前后最近的回文时刻
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>
using namespace __gnu_pbds;

struct _t{
    int hour;
    int min;
    _t & operator ++ () {
        ++min;
        if(min == 60){
            min = 0;
            ++hour;
            if(hour == 24) hour = 0;
        }
        return *this;
    }
    _t & operator -- () {
        --min;
        if(min < 0){
            min = 59;
            --hour;
            if(hour < 0){
                hour = 23;
            }
        }
        return *this;
    }
    bool isOK() const {
        int a = hour / 10;
        int b = hour % 10;
        int c = min / 10;
        int d = min % 10;
        return a == d and b == c;
    }
};

ostream & operator << (ostream & os, const _t & rhs) {
    // if(rhs.hour < 10) os << '0';
    os << rhs.hour << ':';
    // if(rhs.min < 10) os << '0';
    os << rhs.min;
    return os;
}

istream & operator >> (istream & is, _t & rhs) {
    is >> rhs.hour;
    char c; is >> c;
    is >> rhs.min;
    return is;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0);
    _t t;
    cin >> t;
    _t tmp = t;
    while(1){
        --t;
        if(t.isOK()) {
            cout << t << "\n";
            break;
        }
        
    }
    t = tmp;
    while(1){
        ++t;
        if(t.isOK()) {
            cout << t << "\n";
            break;
        }
        
    }
    return 0;
}